package com.springcontext.bean;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 循环依赖 代码分析
 */

@Component
public class Abean {

    public static final Logger logger = LoggerFactory.getLogger(Abean.class);

    @Autowired
    private Bbean bbean;

    @Value(value = "${hook:hellworld}")
    public String avalue;

    @PostConstruct
    public void init() {
        logger.warn("PostConstruct {} {} ", avalue, bbean.bvalue);
    }

    public static void main(String[] args) {

        AnnotationConfigApplicationContext annotationConfigApplicationContext =
                new AnnotationConfigApplicationContext(CompentScanConfig.class);

        String[] beanNamesForType1 = annotationConfigApplicationContext.getBeanNamesForType(Abean.class);

        Abean bean = annotationConfigApplicationContext.getBean(Abean.class);
        System.out.println();

    }

}
